//author:jxx

import { relativeTimeRounding } from "moment";

//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
let extension = {
  components: {//动态扩充组件或组件路径
    //表单header、content、footer对应位置扩充的组件
    gridHeader: '',//{ template: "<div>扩展组xx件</div>" },
    gridBody: '',
    gridFooter: '',
    //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
    modelHeader: '',
    modelBody: '',
    modelFooter: ''
  },
  buttons: { view: [], box: [], detail: [] },//扩展的按钮
  methods: {//事件扩展
    getFormOption (field) {
      let option;
      this.editFormOptions.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        })
      })
      return option;
    },
    onInit () {

    },
    searchAfter(data){
      data = data.map((row)=>{
        if(row.reservation_start.length>10){
          row.reservation_start = row.reservation_start.split(' ')[1]
        }
        if(row.reservation_end.length>10){
          row.reservation_end = row.reservation_end.split(' ')[1]
        }
        return row
      })
      return true
    },
    rowClick ({ row, column, event }) {
       this.$refs.table.$refs.table.toggleRowSelection(row);
      return true;
    },
    // addBefore (formData) { //新建保存前formData为对象，包括明细表
    //   return this.veriFromTable(formData)
    // },
    // updateBefore (formData) { //编辑保存前formData为对象，包括明细表、删除行的Id
    //   return this.veriFromTable(formData)
    // },
    // veriFromTable (v) {
    //   let time1 = v.mainData.reservation_start;
    //   let time2 = v.mainData.reservation_end;
    //   let date1 = new Date();
    //   date1.setHours(parseInt(time1.split(":")[0]), parseInt(time1.split(":")[1]), parseInt(time1.split(":")[2]));

    //   let date2 = new Date();
    //   date2.setHours(parseInt(time2.split(":")[0]), parseInt(time2.split(":")[1]), parseInt(time2.split(":")[2]));
    //   if (date1 < date2) {
    //     return true
    //   } else {
    //     this.$Message.error("开始时间不能大于或等于结束时间");
    //     return false
    //   }
    // },
    
    modelOpenAfter(r){
let reservation_code = this.getFormOption('reservation_code')
      if (this.currentAction == 'Add') {
        reservation_code.disabled = false
      } else {
        reservation_code.disabled = true
      }
    }
  }
};
export default extension;
